Skip to content

Comments

v1.9.20 - Fix: condition SQL encoder - allow multiple fields reference chain#136

Merged
gmpassos merged 4 commits intomasterfrom
fix/condition-sqlencoder-multiple-fields-reference-chain
Jan 15, 2026
Merged

v1.9.20 - Fix: condition SQL encoder - allow multiple fields reference chain#136
gmpassos merged 4 commits intomasterfrom
fix/condition-sqlencoder-multiple-fields-reference-chain

Conversation

@gmpassos
Copy link
Contributor

  • ConditionSQLEncoder:

    • keyToSQL: added check to throw ConditionEncodingError if keys is empty.
    • Refactored keyFieldReferenceToSQL to recursively resolve multi-level key references by walking keys and resolving intermediate tables and relationships.
    • Added helper methods _resolveReferenceField and _resolveFinalField to modularize reference resolution logic.
  • DBSQLAdapter:

    • Introduced _JoinEntry typedef to represent SQL JOIN fragments with explicit alias dependencies (defs and refs).
    • Added local extension methods on List<_JoinEntry> to perform dependency-aware sorting of JOINs ensuring referenced aliases are resolved before use.
    • Refactored JOIN construction logic in SQL query building to:
      • Collect JOINs as _JoinEntry with defined and referenced aliases.
      • Sort JOINs by alias dependencies before concatenation.
      • Log a warning if not all JOIN references could be resolved.
    • This improves correctness and ordering of JOIN clauses in generated SQL.
  • Dependencies:

    • Updated async_extension from ^1.2.17 to ^1.2.18.
    • Updated build_runner from ^2.10.4 to ^2.10.5.

- `ConditionSQLEncoder`:
  - `keyToSQL`: added check to throw `ConditionEncodingError` if `keys` is empty.
  - Refactored `keyFieldReferenceToSQL` to recursively resolve multi-level key references by walking keys and resolving intermediate tables and relationships.
  - Added helper methods `_resolveReferenceField` and `_resolveFinalField` to modularize reference resolution logic.

- `DBSQLAdapter`:
  - Introduced `_JoinEntry` typedef to represent SQL JOIN fragments with explicit alias dependencies (`defs` and `refs`).
  - Added local extension methods on `List<_JoinEntry>` to perform dependency-aware sorting of JOINs ensuring referenced aliases are resolved before use.
  - Refactored JOIN construction logic in SQL query building to:
    - Collect JOINs as `_JoinEntry` with defined and referenced aliases.
    - Sort JOINs by alias dependencies before concatenation.
    - Log a warning if not all JOIN references could be resolved.
  - This improves correctness and ordering of JOIN clauses in generated SQL.

- Dependencies:
  - Updated `async_extension` from ^1.2.17 to ^1.2.18.
  - Updated `build_runner` from ^2.10.4 to ^2.10.5.
@gmpassos gmpassos changed the title v1.9.20 v1.9.20 - Fix: condition SQL encoder - allow multiple fields reference chain Jan 14, 2026
@codecov
Copy link

codecov bot commented Jan 14, 2026

Codecov Report

❌ Patch coverage is 82.50000% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.50%. Comparing base (ca75f8a) to head (3b1c3eb).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
lib/src/bones_api_condition_sql.dart 75.00% 12 Missing ⚠️
lib/src/bones_api_entity_db_sql.dart 93.75% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #136      +/-   ##
==========================================
+ Coverage   65.11%   65.50%   +0.39%     
==========================================
  Files          62       62              
  Lines       20954    20966      +12     
==========================================
+ Hits        13644    13734      +90     
+ Misses       7310     7232      -78     
Flag Coverage Δ
unittests 65.50% <82.50%> (+0.39%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gmpassos gmpassos merged commit dfe6640 into master Jan 15, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant